package com.ardo.controller;

import com.ardo.entity.mall.WxUser;
import com.ardo.entity.query.ProductQuery;
import com.ardo.service.BaseService;
import com.ardo.service.UserService;
import com.ardo.utils.AppUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/base")
public class BaseController {

    @Autowired
    private BaseService baseService;

    @Autowired
    private UserService userService;


    /**
     * 参数属性查询接口
     * 接口编号 A000
     * @param request
     * @return
     */
    @RequestMapping("/queryParam")
    public String queryParam(HttpServletRequest request) {
        AppUtils.printTitle("A000 - 参数属性查询接口");
        String keys  = request.getParameter("keys");
        System.out.println("查询属性 -> " + keys);
        String result = baseService.queryParam(keys);
        return result;
    }

    /**
     * 查询轮播图数据接口
     * 接口编号 A001
     * @param request
     * @return
     */
    @RequestMapping("/queryBanner")
    public String queryBanner(HttpServletRequest request) {
        AppUtils.printTitle("A001 - 查询轮播图数据接口");
        String result = baseService.queryBannerList();
        return result;
    }

    /**
     * 查询首页宫格分类BOX接口
     * 接口编号 A002
     * @param request
     * @return
     */
    @RequestMapping("/queryIndexCateBox")
    public String queryIndexCateBox(HttpServletRequest request) {
        AppUtils.printTitle("A002 - 查询首页宫格分类BOX接口");
        String result = baseService.queryIndexCateBox();
        return result;
    }

    /**
     * 商品分类查询接口
     * 接口编号 B001
     * @param request
     * @return
     */
    @RequestMapping("/queryCategoryList")
    public String queryCategoryList(HttpServletRequest request) {
        AppUtils.printTitle("B001 - 商品分类查询接口");
        String result = baseService.queryCategoryList();
        return result;
    }

    /**
     * 商品列表查询接口
     * 接口编号 B002
     * @param request
     * @return
     */
    @RequestMapping("/queryProductList")
    public String queryProductList(HttpServletRequest request) {
        AppUtils.printTitle("B002 - 商品列表查询接口");
        ProductQuery query = new ProductQuery();
        String result = baseService.queryProductList(query);
        return result;
    }

    /**
     * 查询用户详情
     * 接口编号 C001
     * @param request
     * @return
     */
    @RequestMapping("/userDetail")
    public String userDetail(HttpServletRequest request) {
        AppUtils.printTitle("C001 - 查询用户详情");
        String token  = request.getParameter("token");
        String result = userService.userDetail(token);
        System.out.println("用户详情结果:" + result);
        return result;
    }


}
